import request from "@/utils/request";
// 管理员查询对象
export interface SuperPageQuery {
  /** 搜索关键字 */
  name?: string;
  current?: number;
  pageSize?: number;
}
/** 管理员数据分页对象 */
export interface SuperVO {
  createdAt?: string;
  id?: number;
  lastLoginAt?: string;
  name?: string;
  phone?: number;
  roleId?: number;
  username?: string;
}
/** 管理员表单对象 */
export interface SuperForm {
  roleId?: number;
  roleName?: string;
  username: string;
  password: string;
  name: string;
  isPhone?: boolean;
  phone: string;
  // roleName: string;
}
class superAPI {
  /** 获取管理员数据分页列表 */
  static getSuperAdmin() {
    return request<any, SuperVO[]>({
      url: "/api/super-admin",
      method: "get",
      // data: params,
    });
  }
  /** 新增 + 修改管理员数据分页列表 */
  static updateSuperAdmin(params: SuperForm) {
    return request({
      url: "/api/super-admin",
      method: "post",
      data: params,
    });
  }
  /** 删除管理员数据分页列表 */
  static deleteSuperAdmin(id: string, params: { username: string }) {
    return request({
      url: `/api/super-admin/${id}`,
      method: "delete",
      data: params,
    });
  }
  /** 修改超级管理员密码 */
  static modifySuperAdminPassword(
    id: string,
    params: { oldPassword: string; newPassword: string }
  ) {
    return request({
      url: `/api/super-admin/${id}/change-password`,
      method: "put",
      data: params,
    });
  }
  /** 根据ID查询用户返回角色菜单信息 */
  static getSuperInfo(id: number) {
    return request<any, SuperVO>({
      url: `/api/super-admin/${id}`,
      method: "get",
      // data: params,
    });
  }
}

export default superAPI;
